﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class MemoryManagement
{
    static void Main()
    {
        //BufferedConsole bf = new BufferedConsole();
        //using (bf)
        //{
        //    bf.Write("some random string\n");
        //}
        //Console.WriteLine("End of main");


        //List<Resource> rl = new List<Resource>()
        //{
        //    new Resource("one"),
        //    new Resource("two"),
        //    new Resource("three"),
        //    new Resource("four"),
        //    new Resource("five"),
        //    new Resource("six"),
        //};
        //ResourcePool rp = new ResourcePool(rl);
        //Resource res1 = rp.GetResource();
        //Console.WriteLine(res1.Data);
        //Resource res2 = rp.GetResource();
        //Console.WriteLine(res2.Data);
        //Resource res3 = rp.GetResource();
        //Console.WriteLine(res3.Data);
        //res1.Release();
        //Resource res4 = rp.GetResource();
        //Console.WriteLine(res4.Data);



        PooledResource pr = new PooledResource();
        PooledResource one = pr.GetInstance();
        one = pr.GetInstance();
        using (one)
        { }
        one = pr.GetInstance();
        Console.WriteLine(one);
    }
}

